package com.lxl.testHd.etl.one;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * @author ：e_lixilin
 * @date ：2022/2/21 14:32
 * @description：
 * @modified By：
 */
public class OneEtlDriver {
    public static void main(String[] args) throws Exception{
        args = new String[]{"D:\\big-data\\etl", "D:\\big-data\\etl\\outputwcone"};
        Configuration conf = new Configuration();
        // 获取job对象
        Job job = Job.getInstance(conf);
        // 设置jar的位置
        job.setJarByClass(OneEtlDriver.class);
        // 关联map和reducer类型
        job.setMapperClass(EtlOneMapper.class);
        job.setReducerClass(EtlOneReducer.class);
        // 设置map阶段的输出key和 value类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);
        // 设置reducer阶段,就是最终结果的输出key和value
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);
        // 设置 输入路径和输出路径
        FileInputFormat.setInputPaths(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));
        // 提交job
        boolean result = job.waitForCompletion(true);
        System.exit(result?0:1);

    }
}
